import { Controller, Get, Post, Body, Param } from '@nestjs/common';
import { RolePermissionsService } from './role-permissions.service';
import { CreateRolePermissionDto } from './dto/create-role-permission.dto';
import { UpdateRolePermissionDto } from './dto/update-role-permission.dto';
import { ApiOperation, ApiTags } from '@nestjs/swagger';

@ApiTags('角色权限')
@Controller('role-permissions')
export class RolePermissionsController {
  constructor(
    private readonly rolePermissionsService: RolePermissionsService,
  ) {}

  @ApiOperation({ summary: '创建角色权限' })
  @Post('create')
  create(@Body() createRolePermissionDto: CreateRolePermissionDto) {
    return this.rolePermissionsService.create(createRolePermissionDto);
  }

  @ApiOperation({ summary: '查询所有角色权限' })
  @Get('queryAll')
  findAll() {
    return this.rolePermissionsService.findAll();
  }

  @ApiOperation({ summary: '查询角色权限' })
  @Get('query/:id')
  findOne(@Param('id') id: string) {
    return this.rolePermissionsService.findOne(+id);
  }

  @ApiOperation({ summary: '编辑角色权限' })
  @Post('update/:id')
  update(
    @Param('id') id: string,
    @Body() updateRolePermissionDto: UpdateRolePermissionDto,
  ) {
    return this.rolePermissionsService.update(+id, updateRolePermissionDto);
  }

  @ApiOperation({ summary: '删除角色权限' })
  @Post('remove/:id')
  remove(@Param('id') id: string) {
    return this.rolePermissionsService.remove(+id);
  }
}
